<template>
  <!-- 根div -->
  <div class="login_container">

    <el-row>
      <el-col :span="12">
        <div class="login_left"></div>
      </el-col>
      <el-col :span="12" class="right">
        <!-- 登录表单 -->
        <div class="login_right">
          <h3 align="center" style="margin-bottom: 20px">稻草开发平台</h3>
          <el-form ref="form" :model="loginFrom" label-width="80px" class="login_form">
            <!-- 用户名 -->
            <el-form-item>
              <el-input v-model="loginFrom.account" placeholder="输入用户名">
                <template #prefix>
                  <el-icon>
                    <el-icon>
                      <UserFilled/>
                    </el-icon>
                  </el-icon>
                </template>
              </el-input>

            </el-form-item>
            <!-- 密码 -->
            <el-form-item>
              <el-input v-model="loginFrom.password" type="password" placeholder="输入密码">
                <template #prefix>
                  <el-icon>
                    <Hide/>
                  </el-icon>
                </template>
              </el-input>
            </el-form-item>
          </el-form>
          <!--   记住我，忘记密码   -->
          <div>
            <el-checkbox v-model="checked1" label="记住我" size="large"/>
            <el-text class="mx-1" type="primary" style="cursor: pointer;margin-left: 365px">忘记密码？</el-text>
          </div>
          <div>
            <el-divider>其它登录方式</el-divider>
          </div>
          <!--其它登录方式-->
          <div class="icon-container">
            <div style="margin-left: 10px">
              <el-icon style="margin-left: 20px">
                <ChromeFilled/>
              </el-icon>
              <el-icon style="margin-left: 20px">
                <Eleme/>
              </el-icon>
              <el-icon style="margin-left: 20px">
                <ElemeFilled/>
              </el-icon>
            </div>
          </div>
          <el-button type="primary" class="login_button" @click="handleLogin">登录</el-button>
        </div>
      </el-col>
    </el-row>

  </div>
</template>

<script setup>
//导入ref
import {ref} from 'vue'
//导入login方法
import {login} from '@/api/auth/index'
//登录表单绑定值
const loginForm = ref({
  account: undefined,
  password: undefined
})

//声明 登录方法
function handleLogin() {
  //调用登录方法
  login(loginForm).then((res) => {
    //判断是否成功
    console.log("登录：",res)
    if(res.data.code == 200){
      console.log("登录成功")
      //TODO:将token存入pinia中
    }
  })
};

</script>

<style lang="scss" scoped>
.login_left {
  height: 100vh;
  background-image: url("@/assets/bgImage/2.png");
  background-size: cover;
  background-position: center;
}

.right {
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  border: 1px solid red;
}

.login_right {
  border: 1px solid red;
  height: 500px;
  width: 500px;

  .login_form {
    margin-left: -80px;
  }

  .icon-container {
    display: flex;
    width: auto;
    justify-content: center;
    margin-right: 30px; /* 设置图标之间的右边距 */
    border: 1px solid red;
  }

  .login_button {
    margin-top: 20px;
    width: 100%;

  }
}

</style>
